angular.module('popup', [])
    .factory('popup', [
        '$ionicPopup', '$timeout',
        function($ionicPopup, $timeout) {
            var alert, alertPopup, confirm, confirmPopup, myPopup, show;
            myPopup = void 0;
            show = function(template, time) {
                if (myPopup) {
                    myPopup.close();
                }
                time = time || 1000;
                myPopup = $ionicPopup.show({
                    template: template
                });
                $timeout((function() {
                    myPopup.close();
                }), time);
            };
            confirmPopup = void 0;
            confirm = function(template, ok) {
                if (confirmPopup) {
                    confirmPopup.close();
                }
                confirmPopup = $ionicPopup.confirm({
                    template: template || '是否保存？',
                    cancelText: '取消',
                    okText: ok || '确定'
                });
                return confirmPopup;
            };
            alertPopup = void 0;
            alert = function(template) {
                if (alertPopup) {
                    alertPopup.close();
                }
                alertPopup = $ionicPopup.alert({
                    template: template || '',
                    okText: '确定'
                });
            };
            return {
                show: show,
                confirm: confirm,
                alert: alert
            };
        }
    ]);
